package com.dingwen.treasure.manage.search;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.SearchBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * UserSearchVO: TODO base controller 整合分离
 * 　@author dingwen
 * 　@date 2022/7/2
 */
@SearchBean(
        tables = "user t1 left join user_relation t2 on t1.user_id = t2.user_id   " +
                "         left join user_info t3 on t2.user_info_id = t3.user_info_id",// 三表关联
        //joinCond = "t1.user_id = t2.user_id and t2.user_info_id = t3.user_info_id",// 关联关系 全连接时指定
        autoMapTo = "t1",// 未被 @DbField 注解的字段都映射到 t1 表
        distinct = true,
        orderBy = "t1.user_id desc"
)
@ApiModel(value = "UserSearchVO",description = "user列表信息")
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Builder
public class UserSearchVo implements Serializable {

    private static final long serialVersionUID = -7231111573464150411L;

    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "电话")
    @DbField("t3.phone")
    private String phone;

    @ApiModelProperty(value = "关系名称")
    @DbField("select t4.dic_name from user_relation_dic t4 where t4.dic_id = t2.relation_dic")// 子查询
    private String dicName;
}
